import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { tanstackRouter } from '@tanstack/router-plugin/rspack';

import { getBuildTime } from './build/config';

export default defineConfig({
  plugins: [pluginReact()],
  resolve: {
    alias: {
      '@': './src',
      '@views': './src/views',
      '@three': './src/three',
      '@components': './src/components',
    },
  },
  source: {
    define: {
      BUILD_TIME: JSON.stringify(getBuildTime()),
    },
  },
  tools: {
    rspack: {
      plugins: [
        tanstackRouter({
          target: 'react',
          autoCodeSplitting: true,
          routesDirectory: './src/pages',
          generatedRouteTree: './src/router/routeTree.gen.ts',
          routeFileIgnorePrefix: '-',
          quoteStyle: 'single',
          routeTreeFileHeader: [
            '// biome-ignore-all lint: <auto generate and no lint>',
            '// biome-ignore-all assist/source/organizeImports: <auto generate and no lint>',
            '// @ts-nocheck',
            '// noinspection JSUnusedGlobalSymbols',
          ],
        }),
      ],
    },
  },
});
